﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %> 
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CreateDeptUserControl.ascx.cs" Inherits="JM.JCY.SharePointComponent.UserManagement.CreateDept.CreateDeptUserControl" %>
<%@ Assembly Name="NCS.IConnect.ApplicationContexts, Version=3.9.0.0, Culture=neutral, PublicKeyToken=a20767533a162583" %> 
<%@ Import Namespace="NCS.IConnect.ApplicationContexts" %>
<%@ Register Src="../LeftMenu/LeftMenuUserControl.ascx" TagName="LeftMenuUserControl" TagPrefix="uc1" %>
<script src="/_layouts/JM.JCY.Resource/scripts/jQuery.dualListBox-1.3.js" language="javascript" type="text/javascript"></script>
<link href="/_layouts/JM.JCY.Resource/styles/JCYCSS1.css" rel="stylesheet" type="text/css" />

<script language="javascript" type="text/javascript">
    function IsExistDeptByName(sender, args) {
        var deptName = trim($("#<%= txtDeptName.ClientID %>").val());
        $.support.cors = true;
        $.ajax({
            //async: false,
            type: "GET",
            url: UserManagementServiceUrl + "IsExistDept?DeptName=" + deptName,
            contentType: "application/json; charset=utf-8",
            dataType: 'jsonp',
            cache: false,
            success: function (result) 
            {
                if (result > 0) {
                    args.IsValid = false;
                    $("#<%= hfExist.ClientID %>").val("true");
                    $("#<%= cvCategory.ClientID %>").show();
                }
                else {
                    args.IsValid = true;
                    $("#<%= hfExist.ClientID %>").val("false");
                    $("#<%= cvCategory.ClientID %>").hide();
                }
            },
            failure: function (msg) {
                alert(msg);
            }
        
        });
    }


   
    
    function CheckSelectedItem(sender, args) {
        if (CheckSelected() == false)
            args.IsValid = false;
        else
            args.IsValid = true;
    }

    function CheckSelected() {
        var selCount = 0;
        $.each($("#<%= box2View.ClientID %> option"), function (id, own) {
            selCount++;
        });

        if (selCount == 0)
            return false;
        else
            return true;
    }

    function CheckPageValid() {
        var valid = true;

        if (trim($("#<%= txtDeptName.ClientID %>").val()) == "") {
            $("#<%= rfCategory.ClientID %>").show();
            valid = false;
        }
        else
            $("#<%= rfCategory.ClientID %>").hide();

        if ($("#<%= hfExist.ClientID %>").val() == "true") {
            $("#<%= cvCategory.ClientID %>").show();
            valid = false;
        }

        if (CheckSelected() == false) {
            valid = false;
            $("#<%= cvItem.ClientID %>").show();
        }
        else
            $("#<%= cvItem.ClientID %>").hide();

        if (valid == true) {
            GetSelectedItems();
        }
        return valid;
    }

    function GetSelectedItems() {
        var hfItems = $("#<%=hfItems.ClientID %>");
        hfItems.val("");
        var selItems = "";
        $.each($("#<%= box2View.ClientID %> option"), function (id, own) {
        var value = $(own).val();
            if (value != "")
                selItems = selItems + value + ",";
        });
        hfItems.val(selItems);
    }

    function getClientId() {
        var paraId1 = '<%= box1View.ClientID %>';
        var paraId2 = '<%= box2View.ClientID %>';
        return { Id1: paraId1, Id2: paraId2 };
    } 


    $(function () {

        $.configureBoxes();

    });

</script>
<style type="text/css">
 #warning { display: none; }

    table.ms-rtetoolbarmenu{
        width:100%;
    } 

    iframe.ms-rtelong{ 
        width:100%;
    } 
    .style1
    {
        height: 20px;
    }
    
    .countLabel 
    {
        color:Gray;
        font-style:italic;
    }

    .storageBox 
    {
        display:none;
    }

    .copiedOption
    {
        background-color:Yellow;
    }

    .style2
    {
        color: #CC3300;
    }

</style>

<table class="main">
        <tr>
            <td valign="top" width="25%" runat="server" id="tdLeftMenu">
                <uc1:LeftMenuUserControl ID="LeftMenuUserControl1" runat="server" />
            </td>
            <td valign="top" width="75%" runat="server" id="tdContent">
                <table class="content" width="98%">
                    <tr>
                        <td style="padding: 5px;">
                            <table width="100%" class="title">
                                <tr>
                                    <td width="60%">
                                        <h2 class="title">
                                            <asp:Label ID="lblTitle" runat="server" Text="部门管理"></asp:Label>
                                        &nbsp;- 创建部门</h2>
                                    </td>
                                    <td align="right" width="40%">
                                       
                                   
                                        <%--<input id="isHRAdmin" type="text" value="<%=isHRAdmin %>" style="display: none" />--%>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <table width="85%" class="form">
                                <tr>
                                    <td width="26%">
                                        <b>部门名称</b><span class="style2">*</span>
                                    </td>
                                    <td width="1%">
                                        :
                                    </td>
                                    <td width="73%">
                                        <asp:TextBox ID="txtDeptName" runat="server" MaxLength="100" Width="100%"></asp:TextBox>    <br />
                                 
                                            <asp:RequiredFieldValidator ID="rfCategory" runat="server" ErrorMessage="请输入一个部门名称."
                                                ValidationGroup="SaveInfo" ControlToValidate="txtDeptName" CssClass="ms-formvalidation"
                                                Display="Dynamic"></asp:RequiredFieldValidator>
                                            <asp:CustomValidator ID="cvCategory" runat="server" ErrorMessage="该部门已经存在."
                                                ValidationGroup="SaveInfo" ControlToValidate="txtDeptName" CssClass="ms-formvalidation"
                                                Display="Dynamic" ClientValidationFunction="IsExistDeptByName"></asp:CustomValidator>
                                     </td>
                                </tr>
                                <tr>
                                    <td>
                                        <b>部门描述</b>
                                    </td>
                                    <td>
                                        :
                                    </td>
                                    <td>
                                 <textarea id="txtDeptDescription" name="txtCommitteeDescription" rows="10" cols="80" style="width: 100%" runat="server"></textarea> 
                                    </td>
                                </tr>
                           <tr><td></td><td></td><td></td><td></td><td></td></tr>
                                      <tr><td></td><td></td><td></td><td></td><td></td></tr>
                                <tr>
                                    <td>
                                        &nbsp;</td>
                                    <td>
                                        &nbsp;</td>
                                    <td>
                          
                                        <table width=100% border="0">
                                            <tr>
                                                <td width="40%" valign=bottom style='padding-left:0px; padding-right:0px' 
                                                    class="style1">
                                                    所有职位
                                                </td><td width="20%" style='padding-left:0px; padding-right:0px' class="style1">
                                                    &nbsp;
                                                </td><td valign=bottom width="40%" style='padding-left:0px; padding-right:0px' 
                                                    class="style1">
                                                    本部门职位<span class="style2">*</span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style='padding-left:0px; padding-right:0px'>
                                                     筛选: <input width="100%" type="text" id="box1Filter" />
                                          
                                                    <select runat=server id="box1View" multiple="true" style="height:150px;width:100%;"></select><br />
                                                     <span id="box1Counter" class="countLabel"></span>
                                                    <select id="box1Storage"></select>
                                                                                                   
                                                </td>
                                                <td valign=bottom align=center style='padding-left:0px; padding-right:0px'>
                                                <table >
                                                   <tr>
                                                        <td>
                                                          &nbsp;
                                                        </td>
                                                    </tr>
                                                       <tr>
                                                        <td>
                                                          &nbsp;
                                                        </td>
                                                    </tr>
                                                       <tr>
                                                        <td>
                                                          &nbsp;
                                                        </td>
                                                    </tr>
                                                
                                                      <tr>
                                                        <td>
                                                              <img id="allTo2" class='cl_addBtn_OA' src ='/_layouts/JM.JCY.Resource/images/add_sign.png' alt='Add' />
                                                   
                                                     
                                                        </td>
                                                    </tr>
                                                      <tr>
                                                        <td>
                                                           <img id="allTo1" class='cl_addBtn_OA' src ='/_layouts/JM.JCY.Resource/images/remove_sign.png' alt='Remove' />
                                              
                                                        </td>
                                                    </tr>
                                                 
                                                    </table>
                                                 </td>

                                                <td style='padding-left:0px; padding-right:0px'>                                                    
                                                     筛选: <input width="100%" type="text" id="box2Filter"/><br />

                                                            <select id="box2View" runat=server name="box2View" multiple="true" style="width:100%; height:150px">
                                                          
                                                            </select><br/>
                                                             <br />
                                                         
                                                            <span id="box2Counter" class="countLabel"></span>

                                                            <select id="box2Storage">

                                                            </select>                                       
                                                </td>
                                               
                                                                                  
                                            </tr>
                                                 <tr>
                                                    <td colspan="3">
                                                        <asp:CustomValidator ID="cvItem" runat="server" ClientValidationFunction="CheckSelectedItem"
                                                            CssClass="ms-formvalidation" ValidationGroup="SaveInfo" Display="Dynamic" ErrorMessage="请至少选择一个职位."
                                                            ValidateEmptyText="true"></asp:CustomValidator>
                                                    </td>
                                                </tr>
                                         
                                        </table>                                                                                
                                 

                                    </td>
                                </tr>
                       
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                         <asp:ImageButton ID="imgbtnSave" runat="server" ImageUrl="/_layouts/JM.JCY.Resource/images/save.png"
                                                ValidationGroup="SaveInfo" OnClientClick="if(CheckPageValid()==false)return false;"
                                                OnClick="imgbtnSave_Click" />
                                             
                                  
                                
                                    <asp:ImageButton ID="imgbtnCancel" runat="server" CssClass="cancel"
                                        ImageUrl="/_layouts/JM.JCY.Resource/images/cancel.png" onclick="imgbtnCancel_Click" /> 
                     
                        </td>
                    </tr>
                
                </table>
            </td>
        </tr>
</table>

<asp:HiddenField ID="hfExist" runat="server" />
<asp:HiddenField ID="hfItems" runat="server" />
<asp:HiddenField ID="hfContextId" runat="server" />
